//
//  SRAimSportView.m
//  SportRing
//
//  Created by icelee on 14-10-27.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRAimSportView.h"
#import "UICountingLabel.h"
#import "HKCircleChartView.h"

@implementation SRAimSportViewModel

- (id)initWithAimDistance:(NSInteger)aimDistance chartProcess:(float)chartProcess{
    
    self = [super init];
    if (self) {
        self.aimDistance = aimDistance;
        self.chartViewProcess = chartProcess;
    }
    return self;
}

@end

@interface SRAimSportView ()<HKCircleChartViewDataSoucre>

@property (nonatomic, weak)IBOutlet UICountingLabel *aimDistanceCountingLabel;
@property (nonatomic, weak)IBOutlet UILabel *aimDistanceTextLabel;
@property (nonatomic, weak)IBOutlet UIView *aimChartViewContainerView;
@property (nonatomic, weak)IBOutlet UIView *gifContainerView;

@end

@implementation SRAimSportView

- (void)awakeFromNib{
    
    [super awakeFromNib];
    
    [self setBackgroundColor:[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0f]];
    
    [self.aimDistanceCountingLabel setTextColor:[UIColor colorWithRed:150.0/255.0 green:148.0/255.0 blue:135.0/255.0 alpha:1.0f]];
    self.aimDistanceCountingLabel.format = @"%d";
    [self.aimDistanceTextLabel setTextColor:[UIColor colorWithRed:150.0/255.0 green:148.0/255.0 blue:135.0/255.0 alpha:1.0f]];
    
    [self setGifView];
}

- (void)setSRAimSportViewDataWithModel:(SRAimSportViewModel*)srAimSportViewModel{
    
    self.aimDistanceCountingLabel.method = UILabelCountingMethodEaseIn;
    
    [self.aimDistanceCountingLabel countFrom:0 to:srAimSportViewModel.aimDistance withDuration:1.0];
    
    [self.aimDistanceCountingLabel setCompletionBlock:^{
        
        self.aimDistanceCountingLabel.text = [NSString stringWithFormat:@"%ld",(long)srAimSportViewModel.aimDistance];
    }];
    
    [self setAimChartViewWithProcess:srAimSportViewModel.chartViewProcess];
    
}

- (void)setAimChartViewWithProcess:(float)process{
    
    HKCircleChartView *aimChartView = [[HKCircleChartView alloc] initWithFrame:CGRectMake(0, 0, self.aimChartViewContainerView.frame.size.width, self.aimChartViewContainerView.frame.size.height)];
    
    aimChartView.dataSoucre = self;
    
    [self.aimChartViewContainerView addSubview:aimChartView];
    
    [aimChartView makeCircleChartProcess:process animation:YES];

}

- (void)setGifView{
    

}

#pragma mark - HKCircleChartViewDataSoucre

- (HKCircleChartSettingModel *)circleChartViewSettingModel{
    
    HKCircleChartSettingModel *model = [[HKCircleChartSettingModel alloc] init];
    
    model.clockwise = YES;
    
    model.ringWidth = 15;
    
    model.animationDuration = 0.5;
    
    model.circleColer = [UIColor colorWithRed:116.0/255.0 green:168.0/255.0 blue:31.0/255.0 alpha:1.0f];
    
    model.circleBGColer = [UIColor colorWithRed:249.0/255.0 green:248.0/255.0 blue:242.0/255.0 alpha:1.0f];
    
    return model;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
